package com.example.demo;

import lombok.ToString;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

//@RunWith(SpringRunner.class)
//@SpringBootTest
public class DemoApplicationTests2 {

	@Test
	public void contextLoads() {

//		String str = "eyJpZCI6IjEyMzEyMyIsIm5hbWUiOiLov5nmmK_lirPotYTnmoTlkI3lrZcifQ";
		String str = "eyJpZCI6IjEyMzEyMyIsIm5hbWUiOiLov5nmmK/lirPotYTnmoTlkI3lrZcifQ==";


		System.out.println(new String(Base64.getDecoder().decode(str)));

	}

	@Test
	public void encode(){

		String str = "{\"id\":\"123123\",\"name\":\"这是劳资的名字\"}";


		try {
			System.out.println(Base64.getEncoder().encodeToString(str.getBytes("utf8")));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

	}

}
